#!/bin/bash
# Copyright (C) 2006,2008 G.P. Halkes
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

{
	echo -e "/* THIS FILE IS AUTOGENERATED BY extractGeneratedStrings. DO NOT EDIT */\n#include <stdlib.h>\n\nconst char *clashStrings[] = {"
	egrep -o '"[^"]*"' "$@" | egrep -o '(\<(__)?LL|%s)[_%a-zA-Z0-9_]+\>' | sort -u | egrep -v '%s%d_%s|%schar|%sint|%svoid|LL_%d|LLretval' | sed -r 's/^(.*)$/"\1",/'
	echo "NULL };"
} > clashStrings.c

if egrep -q '%.*%|%[^s]' clashStrings.c ; then
	echo "More than one format specifier or non %s in extracted string! Aborting"
	rm clashStrings.c
	exit 1
fi
exit 0
